﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using Shoozla.DataModel;

namespace Shoozla.ViewModel
{
    public class SummaryViewModel : ViewModelBase
    {

        public Mp3File Song { get; set; }
        public SummaryViewModel(Mp3File song)
        {
            Song = song;
        }

        #region Commands


        private RelayCommand _CmdClose;
        public RelayCommand CmdClose
        {
            get
            {
                if (_CmdClose == null)
                {
                    _CmdClose = new RelayCommand(param => DoCmdClose(), param => { return true; });
                }
                return _CmdClose;
            }
        }

        #endregion

        #region Do commands

        private void DoCmdClose()
        {
            if (Song.Dirty)
            { 
                //save the song tag
                IMP3Processor mp3Processor = new IDSharpProcessor();
                bool res = mp3Processor.SaveID3Tag(Song);
                if (res) Song.Dirty = false;
            }
            OnRequestClose();
        }
        #endregion


    }
}
